const Koa = require("koa");
const app = new Koa();

//post 请求处理
const bodyParser = require("koa-bodyparser");
app.use(bodyParser());

//跨域处理
const cors = require("@koa/cors");
app.use(cors());

//表单验证
const parameter = require("koa-parameter");
app.use(parameter(app));

//连接数据库
const db = require("./db/index");
db();

//挂载路由
const articleRouter = require("./router/article");
app.use(articleRouter.routes());

//监听3000端口
app.listen(3000, () => {
  console.log("3000 running");
});
